#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	int t;
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			int x;
			cin>>x;
		}
		if(i==1)cout<<1<<endl;
		else if(i==2)cout<<0<<endl;
		else cout<<8<<endl;
	}
	return 0;
}
